<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>${htmlTitle}</title>
<link rel="stylesheet" href="${ctx}/static/css/style.default.css" type="text/css" />
<link rel="stylesheet" href="${ctx}/static/dateRange/dateRange.css" type="text/css" />
<link rel="stylesheet" href="${ctx}/static/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css" />
<script type="text/javascript" src="${ctx}/static/js/plugins/jquery-1.7.min.js"></script>
<script type="text/javascript" src="${ctx}/static/js/plugins/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript" src="${ctx}/static/js/plugins/jquery.cookie.js"></script>
<script type="text/javascript" src="${ctx}/static/js/plugins/jquery.uniform.min.js"></script>
<script type="text/javascript" src="${ctx}/static/js/plugins/jquery.validate.min.js"></script>
<script type="text/javascript" src="${ctx}/static/js/plugins/jquery.tagsinput.min.js"></script>
<script type="text/javascript" src="${ctx}/static/js/plugins/charCount.js"></script>
<script type="text/javascript" src="${ctx}/static/js/plugins/ui.spinner.min.js"></script>
<script type="text/javascript" src="${ctx}/static/js/plugins/chosen.jquery.min.js"></script>
<script type="text/javascript" src="${ctx}/static/js/custom/general.js"></script>
<script type="text/javascript" src="${ctx}/static/js/custom/forms.js"></script>
<script type="text/javascript" src="${ctx}/static/dateRange/dateRange.js"></script>
<script type="text/javascript" src="${ctx}/static/ztree/js/jquery.ztree.core.min.js"></script>
<script type="text/javascript" src="${ctx}/static/ztree/js/jquery.ztree.excheck.min.js"></script>
<script type="text/javascript" src="${ctx}/static/js/custom/script.js"></script>
<script type="text/javascript" src="${ctx}/static/js/custom/ztree.js"></script>

<!--[if IE 9]>
    <link rel="stylesheet" media="screen" href="${ctx}/static/css/style.ie9.css"/>
<![endif]-->
<!--[if IE 8]>
    <link rel="stylesheet" media="screen" href="${ctx}/static/css/style.ie8.css"/>
<![endif]-->
<!--[if lt IE 9]>
	<script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"></script>
<![endif]-->
<script>
$(document).ready(function(){
	
	var setting = {
			check : {
				enable : true
			},
			data : {
				simpleData : {
					enable : true
				}
			},
			callback: {
				beforeClick: beforeClick,
				onCheck: onCheck
			}
		};

	var zNodes = [
        <c:forEach items="${data.list}" var="perm">
            <c:if test="${empty perm.checked}">
            { id:${perm.id}, pId:${perm.pId}, name:"${perm.name}"},
            </c:if>
            <c:if test="${not empty perm.checked}">
            { id:${perm.id}, pId:${perm.pId}, name:"${perm.name}", checked:true },
            </c:if>
        </c:forEach>	              
			];
	
	function beforeClick(treeId, treeNode) {
		var zTree = $.fn.zTree.getZTreeObj("tree");
		zTree.checkNode(treeNode, !treeNode.checked, null, true);
		return false;
	}
	
	function onCheck(e, treeId, treeNode) {
		var zTree = $.fn.zTree.getZTreeObj("tree"),
		nodes = zTree.getCheckedNodes(true),
		v = "";
		for (var i=0, l=nodes.length; i<l; i++) {
			v += nodes[i].id + ",";
		}
		if (v.length > 0 ) v = v.substring(0, v.length-1);
		var res = $("#res");
		res.attr("value", v);
	}

	$.fn.zTree.init($("#tree"), setting, zNodes);
	setting.check.chkboxType = { "Y" : "ps", "N" : "ps" };
	$("#py").bind("change", setCheck);
	$("#sy").bind("change", setCheck);
	$("#pn").bind("change", setCheck);
	$("#sn").bind("change", setCheck);
});
</script>


</head>

<body class="withvernav">

<div class="bodywrapper">
    <div class="topheader">
        <div class="left">
            <h1 class="logo">${htmlTitle}</h1>
            <span class="slogan">后台管理系统</span>
            
            <br clear="all" />
            
        </div><!--left-->
        
        <div class="right">
        	<!--<div class="notification">
                <a class="count" href="ajax/notifications.html"><span>9</span></a>
        	</div>-->
            <div class="userinfo">
            	<img src="${ctx}/static/images/thumbs/avatar.png" alt="" />
                <span>${user.acct}</span>
            </div><!--userinfo-->
            
            <div class="userinfodrop">
            	<div class="avatar">
                	<a href=""><img src="${ctx}/static/images/thumbs/avatarbig.png" alt="" /></a>
                </div><!--avatar-->
                <div class="userdata">
                	<h4>${user.acct}</h4>
                    <span class="email"></span>
                    <ul>
                    	<li><a href="${ctx}/user/editpass">修改密码</a></li>
                        <li><a href="${ctx}/user/logout">退出</a></li>
                    </ul>
                </div><!--userdata-->
            </div><!--userinfodrop-->
        </div><!--right-->
    </div><!--topheader-->
    
    
    <div class="header">
    	<ul class="headermenu">
         	<li><a href="${ctx}"><span class="icon icon-flatscreen"></span>首页</a></li>
        	<shiro:hasPermission name="role:*">
            <li class="current"><a href="${ctx}/role/index"><span class="icon icon-pencil"></span>权限管理</a></li>
            </shiro:hasPermission>
        </ul>        
    </div><!--header-->
    
    <div class="vernav" style="position:absolute;left:0;top:185px;">
    	<ul>
    	    <c:forEach items="${menus}" var="menu">
        	<li><a href="${ctx}${menu.resUrl}">${menu.res}</a></li>
        	</c:forEach>
        </ul>
        <a class="togglemenu"></a>
        <br /><br />
    </div><!--leftmenu-->
        
    <div class="centercontent">
    
        <div class="pageheader">
            <h1 class="pagetitle">修改管理员权限</h1>
            <span class="pagedesc">请输入相应信息，创建章节</span>
        </div><!--pageheader-->
        
        <div id="contentwrapper" class="contentwrapper">
            
            <div class="subcontent">
            	
                    <form id="roleform" class="stdform" method="post" action="" enctype="multipart/form-data">
                    
                        <div style="display:block;width:100%;">
                        	<label>权限</label>
                        	<div style="float:left;width:70%;">
		                        <ul id="tree" class="ztree"></ul>
		                    </div>
		                    <input type="text" name="res" id="res" value="${data.perms}" style="display:none;" />
                        </div>
                        
		                <input type="text" name="id" id="id" value="${data.id}" style="display:none;" />
		                <input type="text" name="role" id="role" value="1" style="display:none;" />
		                
                        <p class="stdformbutton" style="float:left;margin-top:50px;">
                        	<button class="submit radius2" style="width:160px;">提交</button>
                        </p>
                        
                        <div style="float:left;width:100%;height:100px;"></div>
                        
                    </form>

            </div><!--subcontent-->
        
        </div><!--contentwrapper-->
        
	</div><!-- centercontent -->
    
    
</div><!--bodywrapper-->

</body>

</html>
